package com.qyhl.module_practice.substreet.detail;


import com.qyhl.module_practice.common.PracticeUrl;
import com.qyhl.webtv.basiclib.utils.network.EasyHttp;
import com.qyhl.webtv.basiclib.utils.network.callback.SimpleCallBack;
import com.qyhl.webtv.basiclib.utils.network.exception.ApiException;
import com.qyhl.webtv.commonlib.entity.civilized.PracticeListBean;

public class StreetDetailModel implements StreetDetailContract.StreetDetialModel {
    private StreetDetailPresenter mPresenter;

    StreetDetailModel(StreetDetailPresenter mPresenter) {
        this.mPresenter = mPresenter;
    }

    @Override
    public void getDetail(String streetId) {
        EasyHttp.get(PracticeUrl.GET_STREET_DETAIL)
                .params("instId", streetId)
                .params("version","1")
                .execute(new SimpleCallBack<PracticeListBean>() {
                    @Override
                    public void onError(ApiException e) {
                        if (e.getCode() == 202) {
                            mPresenter.setError("暂无任何内容！");
                        } else {
                            mPresenter.setError("获取详情失败，请重新尝试！");
                        }
                    }

                    @Override
                    public void onSuccess(PracticeListBean practiceListBean) {
                        mPresenter.setDetail(practiceListBean);
                    }
                });
        
    }
}
